package com.enation.app.javashop.api.client;

import com.enation.app.javashop.model.member.dos.MemberAddress;
import com.enation.app.javashop.service.member.MemberAddressManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 会员地址相关api
 *
 * @author zh
 * @version v7.0
 * @date 18/7/30 下午8:10
 * @since v7.0
 */
@Api(description = "会员地址相关api")
@RestController
@RequestMapping("/client/members/member-address")
@Validated
@ApiIgnore
public class MemberAddressClientController {

    @Autowired
    private MemberAddressManager memberAddressManager;

    @ApiOperation(value = "获取会员地址详细", response = MemberAddress.class)
    @GetMapping("/{id}")
    @ApiImplicitParam(name = "id", value = "会员id", required = true, dataType = "int", paramType = "path")
    public MemberAddress getMemberAddress(@ApiIgnore @PathVariable("id") Long id) {
        return memberAddressManager.getModel(id);
    }

    @ApiOperation(value = "获取会员默认地址", response = MemberAddress.class)
    @GetMapping("/{member_id}/default")
    @ApiImplicitParam(name = "member_id", value = "会员id", required = true, dataType = "int", paramType = "path")
    public MemberAddress getMemberDefaultAddress(@ApiIgnore @PathVariable("member_id") Long memberId) {
        return memberAddressManager.getDefaultAddress(memberId);
    }
}
